package dptest.gxh.cn.dptest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.TextView;

import com.lechange.opensdk.api.LCOpenSDK_Api;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView tvContent=(TextView)findViewById(R.id.tv_content);

        DisplayMetrics dm=new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        int widthPixel=dm.widthPixels;//720
        int heightPixel=dm.heightPixels;//1184
        float xdpi=dm.xdpi;//320.0
        float ydpi=dm.ydpi;//320.0
        int densityDpi=dm.densityDpi;//320
        float density=dm.density;//2.0
        float scaledDensity=dm.scaledDensity;//2.0

        float widthDp=widthPixel/density;//360.0
        float heightDp=heightPixel/density;//592.0
        LCOpenSDK_Api.setHost("");

        tvContent.setText("widthPixel:"+widthPixel+"----"+
                "heightPixel:"+heightPixel+"----"+
                "xdpi:"+xdpi+"----"+
                "ydpi:"+ydpi+"----"+
                "densityDpi:"+densityDpi+"----"+
                "density:"+density+"----"+
                "scaledDensity:"+scaledDensity+"----"+
                "widthDp:"+widthDp+"----"+
                "heightDp:"+heightDp+"----"
        );
    }
}
